using System;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Super
{
	public class BtnRightClick : MonoBehaviour, IPointerDownHandler, IPointerClickHandler, 
	IPointerExitHandler, IDragHandler
	{
		
		public Vector3 scale;
		public Action action;
		private Vector3 oriScale;
		public bool isExit;
		
		public void Start()
		{
			oriScale = transform.localScale;
		}
		
		public void OnPointerDown(PointerEventData eventData)
		{
			if (eventData.button != PointerEventData.InputButton.Right) return;
			isExit = false;
			transform.localScale = Vector3.Scale(oriScale, scale);
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			if (eventData.button != PointerEventData.InputButton.Right) return;
			action?.Invoke(); // 执行回调函数
			transform.localScale = oriScale;
		}
		
		public void OnPointerExit(PointerEventData eventData)
		{
			transform.localScale = oriScale;
		}

        public void OnDrag(PointerEventData eventData)
        {
            // throw new NotImplementedException();
        }
    }

}

